﻿using System;
using System.Web.Routing;

namespace LinkCard.CustomerView
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            RegisterRoutes(RouteTable.Routes);
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }

        private static void RegisterRoutes(RouteCollection routes)
        {
            // Register a route for Categories/All
            // Route name
            // Route URL
            // Web page to handle route
            //routes.MapPageRoute("UserPage", "Users/{*action}", "~/Users.aspx")
            //routes.MapPageRoute("HomePage", "Home", "~/Default.aspx");
            //routes.MapPageRoute("Intro", "Home/Khuyen-Mai", "~/KhuyenMai.aspx")
            //routes.MapPageRoute("Album", "Home/Albums", "~/Album.aspx");
            //routes.MapPageRoute("Photo", "Home/Albums/{AlbumID}_{AlbumName}", "~/Photo.aspx");
            //routes.MapPageRoute("Contact", "Home/Contact", "~/Contact.aspx");
            //routes.MapPageRoute("Menu", "Home/Menu", "~/Menu.aspx");
            //routes.MapPageRoute("Search", "Home/Search", "~/Search.aspx");
            //routes.MapPageRoute("Services", "Home/Services", "~/Services.aspx")
            //routes.MapPageRoute("Article", "{Year}/{Month}/{Day}/{Title}-{ArticleID}", "~/Article.aspx");
            //****************
            //routes.MapPageRoute("ArticleList", "ArticleList/m{mid}c{cid}/{CategoryName}", "~/ArticleList.aspx");
            

            //Get Router Value
            //Page.RouteData.Values["CatID"] -> return string
            //Page.RouteData.Values["SubCat"] -> return string
            //Page.RouteData.Values["CategoryName"] -> return string
            //Demo: http://commodity.vietinbank.vn/c16s4x8/tin-trong-nuoc
            //****************

            // Route to handle Categories/{CategoryName}.
            // The {*CategoryName} instructs the route to match all content after the first slash, which is needed b/c some category names contain a slash, as in the category "Meat/Produce"
            // See http://forums.asp.net/p/1417546/3131024.aspx for more information
            // Route name
            // Route URL
            // Web page to handle route
            //routes.MapPageRoute("View Category", "Categories/{*CategoryName}", "~/CategoryProducts.aspx")

            // Register a route for Products/{ProductName}
            // Route name
            // Route URL
            // Web page to handle route
            //routes.MapPageRoute("View Product", "Products/{ProductName}", "~/ViewProduct.aspx")


            routes.MapPageRoute("Product category", "danh-muc-{pcid}/m-{mid}/{cname}.html", "~/ProductCategory.aspx");
            routes.MapPageRoute("Product ", "san-pham-{did}/m-{mid}/p-{pcid}/{name}.html", "~/Products.aspx");
            routes.MapPageRoute("About Us", "gioi-thieu-{cid}/m-{mid}/{Title}.html", "~/AboutUs.aspx");
            routes.MapPageRoute("Partners", "doi-tac/m-{mid}/{Title}.html", "~/Partners.aspx");
            routes.MapPageRoute("Partner Detail", "doi-tac-{sid}/m-{mid}/{Title}.html", "~/PartnerDetail.aspx");
            routes.MapPageRoute("Article List", "tin-tuc-{cid}/m-{mid}/{cname}.html", "~/ArticleList.aspx");
            routes.MapPageRoute("Article Detail", "tin-tuc-{id}/m-{mid}/c-{cid}/{Title}.html", "~/Article.aspx");
            routes.MapPageRoute("product by tag", "tu-khoa/tag={keyword}.html", "~/ProductList.aspx");
            routes.MapPageRoute("article by tag", "tu-khoa-{cid}/m-{mid}/tag={keyword}.html", "~/ArticleList.aspx");
            routes.MapPageRoute("Register", "dangki.html", "~/Register.aspx");
            routes.MapPageRoute("RegisterSuccess", "dangkithanhcong.html", "~/RegisterSuccess.aspx");

            routes.MapPageRoute("Job Detail", "cong-viec-{jobid}/{Title}.html", "~/JobDetail.aspx");
        }

    }
}